package com.example.newnoke.ui;

import android.databinding.DataBindingUtil;
import android.webkit.WebSettings;
import android.widget.LinearLayout;

import com.example.newnoke.R;
import com.example.newnoke.databinding.ActivityWebBinding;
import com.example.newnoke.mvp.presenter.TestPresenter;
import com.example.newnoke.mvp.view.ITestV;
import com.geya.jbase.baseactivity.BaseDetailsActivity;
import com.just.agentweb.AgentWeb;


/**
 * Created by Administrator on 2018/5/29 0029.
 */

public class WebActivity extends BaseDetailsActivity<TestPresenter> implements ITestV {

    private ActivityWebBinding mBinding;
//    private ActivityWebBinding mBinding;

    private String title;
    private String url;
    private AgentWeb web;
    private LinearLayout mLinearLayout;

    @Override
    public TestPresenter newPresenter() {
        return new TestPresenter(this);
    }

    @Override
    public void init() {
//        mLinearLayout = findViewById(R.id.ll);
        title = getIntent().getStringExtra("title");
        url = getIntent().getStringExtra("url");
        mTitleButton.setTitles(title);


        AndroidInterface androidInterface = new AndroidInterface(this, web);
        androidInterface.setId(getIntent().getStringExtra("id"));
        WebSettings webSettings = mBinding.web.getSettings();
        //支持缩放，默认为true。
        webSettings.setSupportZoom(false);
        //调整图片至适合webview的大小
        webSettings.setUseWideViewPort(true);
        // 缩放至屏幕的大小
        webSettings.setLoadWithOverviewMode(true);
        //设置默认编码
        webSettings.setDefaultTextEncodingName("utf-8");
        //设置自动加载图片
        webSettings.setLoadsImagesAutomatically(true);
mBinding.web.getSettings().setJavaScriptEnabled(true);
        mBinding.web.addJavascriptInterface(androidInterface, "lkl");
        mBinding.web.loadUrl(url);


    }

    @Override
    public void setContentView() {
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_web);
//        setContentView( R.layout.activity_web2);
    }


}
